/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "节点/节点.h"

#include <向量.h>
#include <字符串转换.h>
#include <物体/物体.h>
#include <面/面.h>

//#include "../../Core/bl物体对象.h"
//#include "../../Core/网格处理.h"
#include <core/空间划分/球形八叉树.h>
#include <引擎数据类型.h>



typedef struct {
	vec3	co;
	vec3	normal;
}S_blMesh_顶点;

typedef struct {
	std::vector<uint32>	vertexs;
	uint32			loop_start;
	uint32			loop_total;
	uint32			m_材质ID;
}S_blMesh_多边形;


typedef struct {
	uint32			vertexsID;
	uint32			edgeID;
	uint32			loop_total;
	uint32			m_材质ID;
}S_blMesh_循环;







//void f_socket_resize网格插座数据(std::vector<S_网格插座数据>& data, uint32 num);





class C_物体插座 : public C_插座基类 {
public:
	C_物体插座(std::wstring name);
	~C_物体插座();

	S_物体*			m_Value;

	void*		f_getData(uint8 当前插座连接线ID);
	void		f_setData(void* data, uint8 当前插座连接线ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	std::wstring		f_getTypeName() { return L"ob"; }
};
//typedef C_物体插座 C_Bl网格插座;
//typedef C_物体插座 C_路径插座;
#define DEF_物体插座(socket)  ( dynamic_cast<C_物体插座*>( (socket) ) )
#define DEF_物体插座数据(socket, loc)  ( (S_物体*)( (socket)->f_getData(loc)) )

#define DEF_创建物体插座_I(name) socket = new C_物体插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建物体插座_O(name) socket = new C_物体插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);


//S_物体数据* f_创建物体对象插座数据();






class C_骨架插座 : public C_插座基类 {
public:
	C_骨架插座(std::wstring name);
	~C_骨架插座();

	S_骨架* m_Value;

	void*			f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);

	std::wstring	f_getTypeName() { return L"骨架"; }
};

#define DEF_骨架插座(socket)  ( dynamic_cast<C_骨架插座*>( (socket) ) )
#define DEF_骨架插座数据(socket, loc)  ( (S_骨架*)( (socket)->f_getData(loc)) )

#define DEF_创建骨架插座_I(name) socket = new C_骨架插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建骨架插座_O(name) socket = new C_骨架插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_骨骼插座 : public C_插座基类 {
public:
	C_骨骼插座(std::wstring name);
	~C_骨骼插座();

	S_物体* m_Value;

	void*			f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);

	std::wstring	f_getTypeName() { return L"骨骼"; }
};

#define DEF_骨骼插座(socket)  ( dynamic_cast<C_骨骼插座*>( (socket) ) )
#define DEF_骨骼插座数据(socket, loc)  ( (S_物体*)( (socket)->f_getData(loc)) )

#define DEF_创建骨骼插座_I(name) socket = new C_骨骼插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建骨骼插座_O(name) socket = new C_骨骼插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);









class C_IK插座 : public C_插座基类 {
public:
	C_IK插座(std::wstring name);
	~C_IK插座();

	S_骨骼IK*	m_Value;
	void*		f_getData(uint8 当前插座连接线ID);
	void		f_setData(void* data, uint8 当前插座连接线ID = 0);
};
#define DEF_IK插座(socket) dynamic_cast<C_IK插座*>( (socket) )
#define DEF_IK插座数据(socket)  ((S_骨骼IK*)socket->f_getData())

#define DEF_创建IK插座_I(name) socket = new C_IK插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建IK插座_O(name) socket = new C_IK插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);











class C_网格插座 : public C_插座基类 {
	
public:
	C_网格插座(std::wstring name);
	~C_网格插座();

	//S_网格插座数据	m_Value;
	S_Mesh*	m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string f_构建变量代码(int32 loc);
	bool        f_接入插座是否匹配(E_值类型 type);

	void		f_释放数据();
	std::wstring		f_getTypeName() { return L"mesh"; }
};

#define DEF_转换为网格插座(socket)  dynamic_cast<C_网格插座*>( (socket) )
#define DEF_网格插座数据(socket)  ((S_Mesh*)( (socket)->f_getData(0)) )

#define DEF_创建网格插座_I(name) socket = new C_网格插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建网格插座_O(name) socket = new C_网格插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);


/*
PyObject*	f_构建Py网格数据(const S_网格插座数据& mesh);

bool		f_从Py数据构建网格(S_网格插座数据* mesh, PyObject* item);
*/




class C_多边形插座 : public C_插座基类 {
	S_多边形* m_默认值;
	S_多边形* m_转换值;
public:
	C_多边形插座(std::wstring name);
	~C_多边形插座();

	S_多边形* m_Value;

	void*        f_getData(uint8 当前插座连接线ID);
	void		 f_setData(void* data, uint8 线程ID = 0);
	std::string  f_构建变量代码(int32 loc);
	bool         f_接入插座是否匹配(E_值类型 type);
	void		 f_释放数据();
	std::wstring f_getTypeName() { return L"多边形"; }
};

#define DEF_多边形插座(socket)  dynamic_cast<C_多边形插座*>( (socket) )
#define DEF_多边形插座数据(socket)  ((S_多边形*)( (socket)->f_getData(0)) )

#define DEF_创建多边形插座_I(name) socket = new C_多边形插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建多边形插座_O(name) socket = new C_多边形插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_多边形插座_1D : public C_插座基类 {
	S_多边形Array* m_默认值;
	S_多边形Array* m_转换值;
public:
	C_多边形插座_1D(std::wstring name);
	~C_多边形插座_1D();

	S_多边形Array* m_Value;

	void*	f_getData(uint8 当前插座连接线ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	std::string  f_构建变量代码(int32 loc);
	bool         f_接入插座是否匹配(E_值类型 type);

	std::wstring	f_getTypeName() { return L"[多边形]"; }
};

#define DEF_多边形_1D插座(socket)  dynamic_cast<C_多边形插座_1D*>( (socket) )
#define DEF_多边形_1D插座数据(socket, tid)  ((S_多边形Array*)( (socket)->f_getData(tid)) )

#define DEF_创建多边形_1D插座_I(name) socket = new C_多边形插座_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建多边形_1D插座_O(name) socket = new C_多边形插座_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





class C_多边形面插座_1D : public C_插座基类 {

public:
	C_多边形面插座_1D(std::wstring name);
	~C_多边形面插座_1D();

	std::vector<S_多边形元素*> m_Value;

	void*         f_getData(uint8 当前插座连接线ID);
	void          f_setData(void* data, uint8 线程ID = 0);

	std::wstring  f_getTypeName() { return L"[face]"; }
};

#define DEF_多边形面_1D插座(socket)  dynamic_cast<C_多边形面插座_1D*>( (socket) )
#define DEF_多边形面_1D插座数据(socket, tid)  ((std::vector<S_多边形元素*>*)( (socket)->f_getData(tid)) )

#define DEF_创建多边形面_1D插座_I(name) socket = new C_多边形面插座_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建多边形面_1D插座_O(name) socket = new C_多边形面插座_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);










class C_元素选择插座 : public C_插座基类 {
	S_ElementSelect* m_默认值;
public:
	C_元素选择插座(std::wstring name);
	~C_元素选择插座();

	S_ElementSelect* m_Value;

	void*		f_getData(uint8 当前插座连接线ID);
	void		f_setData(void* data, uint8 当前插座连接线ID = 0);
	bool        f_接入插座是否匹配(E_值类型 type);
};
#define DEF_元素选择插座数据(socket, tid)  ((S_ElementSelect*)( (socket)->f_getData(tid)) )
#define DEF_创建元素选择插座_I(name) socket = new C_元素选择插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建元素选择插座_O(name) socket = new C_元素选择插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






class C_元素数组选择插座 : public C_插座基类 {
	S_ElementSelectArray* m_默认值;
public:
	C_元素数组选择插座(std::wstring name);
	~C_元素数组选择插座();

	S_ElementSelectArray* m_Value;

	void*		f_getData(uint8 当前插座连接线ID);
	void		f_setData(void* data, uint8 当前插座连接线ID = 0);
	bool        f_接入插座是否匹配(E_值类型 type);
};
#define DEF_元素数组选择插座数据(socket, tid)  ((S_ElementSelectArray*)( (socket)->f_getData(tid)) )
#define DEF_创建元素数组选择插座_I(name) socket = new C_元素数组选择插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建元素数组选择插座_O(name) socket = new C_元素数组选择插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





/*
class C_场景插座 : public C_插座基类
{
	//PyObject*		m_Object;
	std::string			m_Object;

public:
	C_场景插座(std::string name);
	~C_场景插座();


	void*		f_getData();
	void		f_setData(void* data);

private:

};
*/











/*
typedef struct {
	vec4		m_平面;
	uint32		m_物体ID;
}S_平面属性;



struct S_物理体;
struct S_物理解算器;

typedef struct {
	S_物理体*	body;
	PyObject*	obj;
	//string		obj;
}S_bl物理体对象包;

typedef struct {
	S_物理解算器*		解算器;
	S_bl物理体对象包	body包;
}S_物理体对象包;


class C_平面插座 : public C_插座基类 {
public:
	C_平面插座(std::string name);
	~C_平面插座();

	S_平面属性	m_平面属性;


	void*		f_getData();
	void		f_setData(void* data, int64 ID = -1);


private:

};
#define DEF_转换为平面插座(socket) dynamic_cast<C_平面插座*>( (socket) )
#define DEF_平面属性插座Value(socket)  ((S_平面属性*)socket->f_getData())
*/



/*
class C_物体数据插座 : public C_插座基类 {
public:
	C_物体数据插座(string name);
	~C_物体数据插座();

	S_物体附属数据*	m_Value;

	void*		f_getData();
	void		f_setData(void* data, int64 ID = -1);

};
#define DEF_转换为物理体插座(socket) dynamic_cast<C_物体数据插座*>( (socket) )
#define DEF_物理体插座Value(socket)  ((S_物体数据*)socket->f_getData())

#define DEF_创建物体数据插座_I(name) socket = new C_物体数据插座( (name) ); f_add插座(socket, E_插座输出方向::e_插座Type_输入);
#define DEF_创建物体数据插座_O(name) socket = new C_物体数据插座( (name) ); f_add插座(socket, E_插座输出方向::e_插座Type_输出);
*/








class C_树路径插座 : public C_插座基类 {
public:
	C_树路径插座(std::wstring name);
	~C_树路径插座();
	
	std::vector<S_八叉树子空间*> m_Value;

	void*	f_getData(uint8 线程ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	void	f_释放数据();
};

#define DEF_树路径插座(socket)  ( dynamic_cast<C_树路径插座*>( (socket) ) )
#define DEF_树路径插座Value(socket, tid)  ( (std::vector<S_八叉树子空间*>*)( (socket)->f_getData(tid)) )

#define DEF_创建树路径插座_I(name) socket = new C_树路径插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建树路径插座_O(name) socket = new C_树路径插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




